package com.xuanmiao.smsback.service.platform.operator.impl;

import com.xuanmiao.smsback.dao.model.AuditRecordInfoDO;
import com.xuanmiao.smsback.dao.model.ExpenseCalendarInfoDO;
import com.xuanmiao.smsback.dao.model.RechargeRecordInfoDO;
import com.xuanmiao.smsback.domain.qo.AuditRecordInfoQO;
import com.xuanmiao.smsback.domain.qo.ListExpenseCalendarInfoQO;
import com.xuanmiao.smsback.domain.qo.RechargeRecordInfoQO;
import com.xuanmiao.smsback.domain.qo.UserListInfoQO;
import com.panshi.hujin2.base.common.util.DozerUtils;
import com.panshi.hujin2.base.domain.page.Page;
import com.xuanmiao.smsback.dao.mapper.UserListInfoMapper;
import com.xuanmiao.smsback.dao.model.UserListInfoDO;

import com.xuanmiao.smsback.model.AuditRecordInfoBO;
import com.xuanmiao.smsback.model.ExpenseCalendarInfoBO;
import com.xuanmiao.smsback.model.RechargeRecordInfoBO;
import com.xuanmiao.smsback.model.UserListInfoBO;
import com.xuanmiao.smsback.service.platform.operator.UserListInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;


@Service
public class UserListInfoServiceImpl implements UserListInfoService {
    @Autowired
    private UserListInfoMapper userListInfoMapper;
    @Override
    public List<UserListInfoBO> getList(UserListInfoQO userListInfoQO) {
        if(userListInfoQO == null){
            userListInfoQO = new UserListInfoQO();
        }
        //获取数量
        Integer count = userListInfoMapper.count(userListInfoQO);
        Page page = userListInfoQO.getPage();
        //设置总记录数
        page.setTotalNumber(count);
        List<UserListInfoDO> userListInfoDO = userListInfoMapper.queryUserListInfo(userListInfoQO);

        if(userListInfoDO!=null && userListInfoDO.size()>0){
            List<UserListInfoBO> areContactInfoBO = DozerUtils.convertList(userListInfoDO, UserListInfoBO.class);

            return areContactInfoBO;
                    //DozerUtils.convertList(areContactInfoMapper.query(areContactInfoQO),UserListInfoBO.class);
        }
        return Collections.emptyList();


    }

    @Override
    public UserListInfoBO getById(Integer id) {

        return DozerUtils.convert(userListInfoMapper.getById(id),UserListInfoBO.class);
    }

    @Override
    public void update(UserListInfoBO areContactInfoBO) {
        userListInfoMapper.update(DozerUtils.convert(areContactInfoBO,UserListInfoDO.class));

    }

    @Override
    public List<RechargeRecordInfoBO> getRechargeById(RechargeRecordInfoQO rechargeRecordInfoQO) {
        if(rechargeRecordInfoQO == null){
            rechargeRecordInfoQO = new RechargeRecordInfoQO();
        }
        //获取数量
        Integer count = userListInfoMapper.countRecharge(rechargeRecordInfoQO);
        Page page = rechargeRecordInfoQO.getPage();
        //设置总记录数
        page.setTotalNumber(count);
        List<RechargeRecordInfoDO> rechargeRecordInfoDO = userListInfoMapper.getRechargeById(rechargeRecordInfoQO);

        if(rechargeRecordInfoDO!=null && rechargeRecordInfoDO.size()>0){
            List<RechargeRecordInfoBO> rechargeRecordInfoBO = DozerUtils.convertList(rechargeRecordInfoDO, RechargeRecordInfoBO.class);

            return rechargeRecordInfoBO;
            //DozerUtils.convertList(areContactInfoMapper.query(areContactInfoQO),UserListInfoBO.class);
        }
        return Collections.emptyList();

    }

    @Override
    public List<ExpenseCalendarInfoBO> getExpenseById(ListExpenseCalendarInfoQO listExpenseCalendarInfoQO) {
        if(listExpenseCalendarInfoQO == null){
            listExpenseCalendarInfoQO = new ListExpenseCalendarInfoQO();
        }
        //获取数量
        Integer count = userListInfoMapper.countExpense(listExpenseCalendarInfoQO);
        Page page = listExpenseCalendarInfoQO.getPage();
        //设置总记录数
        page.setTotalNumber(count);
        List<ExpenseCalendarInfoDO> expenseCalendarInfoDO = userListInfoMapper.getExpenseById(listExpenseCalendarInfoQO);

        if(expenseCalendarInfoDO!=null && expenseCalendarInfoDO.size()>0){
            List<ExpenseCalendarInfoBO> expenseCalendarInfoBO = DozerUtils.convertList(expenseCalendarInfoDO, ExpenseCalendarInfoBO.class);

            return expenseCalendarInfoBO;

        }
        return Collections.emptyList();

    }

    @Override
    public List<AuditRecordInfoBO> getAuditById(AuditRecordInfoQO auditRecordInfoQO) {
        if(auditRecordInfoQO == null){
            auditRecordInfoQO = new AuditRecordInfoQO();
        }
        //获取数量
        Integer count = userListInfoMapper.countAudit(auditRecordInfoQO);
        Page page = auditRecordInfoQO.getPage();
        //设置总记录数
        page.setTotalNumber(count);
        List<AuditRecordInfoDO> auditRecordInfoDO = userListInfoMapper.getAuditById(auditRecordInfoQO);

        if(auditRecordInfoDO!=null && auditRecordInfoDO.size()>0){
            List<AuditRecordInfoBO> auditRecordInfoBO = DozerUtils.convertList(auditRecordInfoDO, AuditRecordInfoBO.class);

            return auditRecordInfoBO;

        }
        return Collections.emptyList();

    }


}
